# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libidn

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.28
pkgrel=2
pkgdesc="Implementation of the Stringprep, Punycode and IDNA specifications (mingw-w64)"
arch=('any')
url="http://www.gnu.org/software/libidn"
license=("GPL3, LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gettext")
options=('staticlibs' 'strip')
source=("ftp://ftp.gnu.org/gnu/libidn/libidn-${pkgver}.tar.gz"
    0001-fix-gtkdoc.all.patch
    0002-fix-gdoc.all.patch)
sha1sums=('725587211b229c156e29fa2ad116b0ef71a7ca17'
          '42baea83d76aeaa99e50f551d98dade8a5394fe3'
          '730dfdfdf3c2878113224c104f9c6c213010d7f0')

prepare() {
  cd "${srcdir}"/libidn-${pkgver}
  patch -p1 -i ${srcdir}/0001-fix-gtkdoc.all.patch
  patch -p1 -i ${srcdir}/0002-fix-gdoc.all.patch

  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/libidn-${pkgver}/configure \
    --prefix=${MINGW_PREFIX}\
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --disable-csharp \
    --disable-java \
    --enable-threads=win32
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
}
